package com.gali.juc;

import java.util.concurrent.atomic.AtomicIntegerArray;

/**
 * @Auther: gali
 * @Date: 2022-08-23 16:32
 * @Description:
 */
public class AtomicIntegerArrayDemo {
    public static void main(String[] args) {
        AtomicIntegerArray atomicIntegerArray=new AtomicIntegerArray(new int[]{1,2,3,4,5});
        for (int i = 0; i < atomicIntegerArray.length(); i++) {
            System.out.println(atomicIntegerArray.get(i));
        }
        System.out.println("--------------");
        int index= 0;
        int andSet = atomicIntegerArray.getAndSet(index, 2022);
        System.out.println(andSet+"\t"+atomicIntegerArray.get(index));
    }
}
